class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int,int> mp;
        vector<int> num;
        for(int i=0;i<nums.size();i++)
        {
            mp[nums[i]]=i+1;
        }
        for(int i=0;i<nums.size();i++)
        {
            int j=target-nums[i];
            if(mp[j] && (mp[j]-1)!=i)
            {
                num.push_back(i);
                num.push_back(mp[j]-1);
                break;
            }
        }
        return num;
    }
};